//
//  DoctorApplyViewController.m
//  QuickCure
//
//  Created by haoge on 16/9/10.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "DoctorApplyViewController.h"
#import "SearchDocModel.h"
#import "SearchDocViewCell.h"
#import "OrderDocMes.h"

@interface DoctorApplyViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) NSArray *dataList;

@property (nonatomic, strong) NSMutableArray *mArray;

@end

@implementation DoctorApplyViewController

#pragma mark
#pragma mark -- 懒加载
- (NSArray *)dataList{
    
    //1. 判断对象是否为nil
    if (_dataList == nil) {
        
        //2. 加载数据
        _dataList = [SearchDocModel sdmWithPlistFileName:@"SearchDoc"];
    }
    
    //3. 返回数据
    return _dataList;
}

- (NSMutableArray *)mArray{
    if (nil == _mArray) {
        _mArray = [NSMutableArray array];
    }
    return _mArray;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"申请名医通";
    
    [self setupUI];
}

#pragma mark
#pragma mark -- 加载UI界面
- (void)setupUI{
    
    UITableView *tableView = [[UITableView alloc] init];
    
    tableView.delegate = self;
    tableView.dataSource = self;
    
    tableView.rowHeight = 90;
    
    UIView *whiteView = [[UIView alloc] init];
    tableView.tableFooterView = whiteView;
    
    [tableView registerClass:[SearchDocViewCell class] forCellReuseIdentifier:@"abcd"];
    
    [self.view addSubview:tableView];
    
    //设置tableView的约束
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.leading.bottom.trailing.equalTo(self.view);
    }];
}

#pragma mark
#pragma mark -- tableView delegate dataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataList.count;
}

- (SearchDocViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    SearchDocViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"abcd" forIndexPath:indexPath];
    SearchDocModel *model = self.dataList[indexPath.row];
    
    NSString *tempStr = model.patient;
    tempStr = [tempStr stringByAppendingFormat:@"   %@",model.state];
    
    [self.mArray addObject:tempStr];
    
    //    NSLog(@"%@",self.mArray);
    
    cell.model = model;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    OrderDocMes *OD = [[OrderDocMes alloc] init];
    
    OD.pMess = self.mArray[indexPath.row];
    //    NSLog(@"%@",OD.pMess);
    
    [self.navigationController pushViewController:OD animated:YES];
}
@end
